shortcut-label: make it public
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 26 Jul 2016 19:00:47 +0000 (16:00 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 27 Jul 2016 19:30:31 +0000 (16:30 -0300)
GtkShortcutLabel is a widget that displays a single
shortcut accelerator or gesture in the user interface,
and is currently used by the shortcuts window.

This widget, however, has public value as other applications
also may want to expose their own shortcuts. For instance,
it'll be useful for the Keyboard panel on Control Center and
the new shortcut editor in Pitivi, among others.

This patch exposes GtkShortcutLabel as a public widget,
and adds the necessary documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=769205

docs/reference/gtk/gtk3.types.in
gtk/Makefile.am
gtk/gtk.h
gtk/gtkshortcutlabel.c
gtk/gtkshortcutlabel.h [new file with mode: 0644]
gtk/gtkshortcutlabelprivate.h [deleted file]
gtk/gtkshortcutsshortcut.c

index beb5a4a57afd4000dc5f581eb9468fbbbdfbab7f..32d57eb940253ad040aab89e289b9c8a46bd5ab8 100644 (file)
@@ -173,6 +173,7 @@ gtk_separator_get_type
 gtk_separator_menu_item_get_type
 gtk_separator_tool_item_get_type
 gtk_settings_get_type
+gtk_shortcuts_label_get_type
 gtk_shortcuts_window_get_type
 gtk_shortcuts_section_get_type
 gtk_shortcuts_group_get_type
index 611b96eac0702ac84da81eda8ed9f4da9c4a7d5a..ed6c224370d9b10277cee596c5284d0439bc00da 100644 (file)
@@ -286,6 +286,7 @@ gtk_public_h_sources =              \
        gtkseparatormenuitem.h  \
        gtkseparatortoolitem.h  \
        gtksettings.h           \
+       gtkshortcutlabel.h      \
        gtkshortcutsgroup.h     \
        gtkshortcutssection.h   \
        gtkshortcutsshortcut.h  \
@@ -548,7 +549,6 @@ gtk_private_h_sources =             \
        gtksearchentryprivate.h \
        gtkselectionprivate.h   \
        gtksettingsprivate.h    \
-       gtkshortcutlabelprivate.h       \
        gtkshortcutswindowprivate.h     \
        gtkshortcutsshortcutprivate.h   \
        gtksidebarrowprivate.h  \
index a7233dadd1037c5c1cd42d77392a9126c354d052..c818f32e97c081ead344b1d64b8d3733b6eac6e1 100644 (file)
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
 #include <gtk/gtkseparatormenuitem.h>
 #include <gtk/gtkseparatortoolitem.h>
 #include <gtk/gtksettings.h>
+#include <gtk/gtkshortcutlabel.h>
 #include <gtk/gtkshortcutsgroup.h>
 #include <gtk/gtkshortcutssection.h>
 #include <gtk/gtkshortcutsshortcut.h>
index 06b173662e5b28616d006bc3a03c292caa8dfad8..45cf3daca53f2ca71ed0921890030c8811e300af 100644 (file)
 
 #include "config.h"
 
-#include "gtkshortcutlabelprivate.h"
+#include "gtkshortcutlabel.h"
 #include "gtklabel.h"
 #include "gtkframe.h"
 #include "gtkstylecontext.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
 
+/**
+ * SECTION:gtkshortcutlabel
+ * @Title: GtkShortcutLabel
+ * @Short_description: Displays a keyboard shortcut
+ * @See_also: #GtkCellRendererAccel
+ *
+ * #GtkShortcutLabel is a widget that represents a single keyboard shortcut or gesture
+ * in the user interface.
+ */
+
 struct _GtkShortcutLabel
 {
   GtkBox  parent_instance;
@@ -438,6 +448,14 @@ gtk_shortcut_label_class_init (GtkShortcutLabelClass *klass)
   object_class->get_property = gtk_shortcut_label_get_property;
   object_class->set_property = gtk_shortcut_label_set_property;
 
+  /**
+   * GtkShortcutLabel:accelerator:
+   *
+   * The accelerator that @self displays. See #GtkShortcutsShortcut:accelerator
+   * for the accepted syntax.
+   *
+   * Since: 3.22
+   */
   properties[PROP_ACCELERATOR] =
     g_param_spec_string ("accelerator", P_("Accelerator"), P_("Accelerator"),
                          NULL,
@@ -452,6 +470,16 @@ gtk_shortcut_label_init (GtkShortcutLabel *self)
   gtk_box_set_spacing (GTK_BOX (self), 6);
 }
 
+/**
+ * gtk_shortcut_label_new:
+ * @accelerator: the initial accelerator
+ *
+ * Creates a new #GtkShortcutLabel with @accelerator set.
+ *
+ * Returns: (transfer full): a newly-allocated #GtkShortcutLabel
+ *
+ * Since: 3.22
+ */
 GtkWidget *
 gtk_shortcut_label_new (const gchar *accelerator)
 {
@@ -460,6 +488,16 @@ gtk_shortcut_label_new (const gchar *accelerator)
                        NULL);
 }
 
+/**
+ * gtk_shortcut_label_get_accelerator:
+ * @self: a #GtkShortcutLabel
+ *
+ * Retrieves the current accelerator of @self.
+ *
+ * Returns: (transfer none)(nullable): the current accelerator.
+ *
+ * Since: 3.22
+ */
 const gchar *
 gtk_shortcut_label_get_accelerator (GtkShortcutLabel *self)
 {
@@ -468,6 +506,15 @@ gtk_shortcut_label_get_accelerator (GtkShortcutLabel *self)
   return self->accelerator;
 }
 
+/**
+ * gtk_shortcut_label_set_accelerator:
+ * @self: a #GtkShortcutLabel
+ * @accelerator: the new accelerator
+ *
+ * Sets the accelerator to be displayed by @self.
+ *
+ * Since: 3.22
+ */
 void
 gtk_shortcut_label_set_accelerator (GtkShortcutLabel *self,
                                     const gchar      *accelerator)
diff --git a/gtk/gtkshortcutlabel.h b/gtk/gtkshortcutlabel.h
new file mode 100644 (file)
index 0000000..aecaa78
--- /dev/null
@@ -0,0 +1,52 @@
+/* gtkshortcutlabelprivate.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian@hergert.me>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public License as
+ *  published by the Free Software Foundation; either version 2 of the
+ *  License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public
+ *  License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_SHORTCUT_LABEL_H__
+#define __GTK_SHORTCUT_LABEL_H__
+
+#include <gtk/gtkbox.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SHORTCUT_LABEL (gtk_shortcut_label_get_type())
+#define GTK_SHORTCUT_LABEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SHORTCUT_LABEL, GtkShortcutLabel))
+#define GTK_SHORTCUT_LABEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SHORTCUT_LABEL, GtkShortcutLabelClass))
+#define GTK_IS_SHORTCUT_LABEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SHORTCUT_LABEL))
+#define GTK_IS_SHORTCUT_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SHORTCUT_LABEL))
+#define GTK_SHORTCUT_LABEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SHORTCUT_LABEL, GtkShortcutLabelClass))
+
+
+typedef struct _GtkShortcutLabel      GtkShortcutLabel;
+typedef struct _GtkShortcutLabelClass GtkShortcutLabelClass;
+
+GDK_AVAILABLE_IN_3_22
+GType        gtk_shortcut_label_get_type        (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_3_22
+GtkWidget   *gtk_shortcut_label_new             (const gchar      *accelerator);
+
+GDK_AVAILABLE_IN_3_22
+const gchar *gtk_shortcut_label_get_accelerator (GtkShortcutLabel *self);
+
+GDK_AVAILABLE_IN_3_22
+void         gtk_shortcut_label_set_accelerator (GtkShortcutLabel *self,
+                                                 const gchar      *accelerator);
+
+G_END_DECLS
+
+#endif /* __GTK_SHORTCUT_LABEL_H__ */
diff --git a/gtk/gtkshortcutlabelprivate.h b/gtk/gtkshortcutlabelprivate.h
deleted file mode 100644 (file)
index 4f5096c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* gtkshortcutlabelprivate.h
- *
- * Copyright (C) 2015 Christian Hergert <christian@hergert.me>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public License as
- *  published by the Free Software Foundation; either version 2 of the
- *  License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public
- *  License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_SHORTCUT_LABEL_H__
-#define __GTK_SHORTCUT_LABEL_H__
-
-#include <gtk/gtkbox.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_SHORTCUT_LABEL (gtk_shortcut_label_get_type())
-#define GTK_SHORTCUT_LABEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SHORTCUT_LABEL, GtkShortcutLabel))
-#define GTK_SHORTCUT_LABEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SHORTCUT_LABEL, GtkShortcutLabelClass))
-#define GTK_IS_SHORTCUT_LABEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SHORTCUT_LABEL))
-#define GTK_IS_SHORTCUT_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SHORTCUT_LABEL))
-#define GTK_SHORTCUT_LABEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SHORTCUT_LABEL, GtkShortcutLabelClass))
-
-
-typedef struct _GtkShortcutLabel      GtkShortcutLabel;
-typedef struct _GtkShortcutLabelClass GtkShortcutLabelClass;
-
-
-GType        gtk_shortcut_label_get_type        (void) G_GNUC_CONST;
-
-GtkWidget   *gtk_shortcut_label_new             (const gchar      *accelerator);
-const gchar *gtk_shortcut_label_get_accelerator (GtkShortcutLabel *self);
-void         gtk_shortcut_label_set_accelerator (GtkShortcutLabel *self,
-                                                 const gchar      *accelerator);
-
-G_END_DECLS
-
-#endif /* __GTK_SHORTCUT_LABEL_H__ */
index 01df8b9affb7d93b549f09fb9ada046871bf8b8a..ca06eabcfc4be8b28f789ded43c1f2b91f7a9d0f 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "gtkshortcutsshortcut.h"
 
-#include "gtkshortcutlabelprivate.h"
+#include "gtkshortcutlabel.h"
 #include "gtkshortcutswindowprivate.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"